using System;

namespace OpenRay
{
	//Immutable Class
	public class DirectionalPhongLight : PhongLight
	{
		private readonly Vector lightDirection;
		
		public DirectionalPhongLight( Color A, Color D, Color S, Vector v, IScene sc )
			: base( A, D, S, sc)
		{
			lightDirection = Vector.Normalize( v );
		}
		
		public override Color ComputeLighting( Color materialAmbient, Color materialDiffuse, Color materialSpecular, float materialShininess,
                                 	   		   Point worldHit, Vector normalizedViewer, Vector surfaceNormal ) {
			Color ambientTerm = BlinnPhongAmbient( materialAmbient );
			
			if ( isShadowed(worldHit, lightDirection) )
				return ambientTerm;
			
			return ambientTerm + BlinnPhongNonAmbient( materialDiffuse, materialSpecular, materialShininess, lightDirection, normalizedViewer, surfaceNormal );;
		}
	}
}

